<template>

    <slot v-if="showSlot" :userPermisstions="permissions"></slot>
</template>

<script setup>
import { useUserStore } from '@/stores/user'
const props = defineProps({
    permissions:{
        type:[String,Array]
    }
})

const {permission} = useUserStore()
watch(() => permission, (newData) => {
    console.log("da")
})


const showSlot = computed(()=>{
    if(!props.permissions){
        return true
    }
    if(!permission){
        return false;
    }
    if(Array.isArray(props.permissions)){
        return props.permissions.every((p)=>permission.includes(p))
    }else{
        return permission.includes(props.permissions);
    }
})
</script>